﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LibraryO2S;
public partial class Administrator_CategoryAdd : System.Web.UI.Page
{
    DataProcess data = new DataProcess();
    protected void Page_Load(object sender, EventArgs e)
    {

    }  
    protected void btnSubmit_Click(object sender, EventArgs e)
    {

        string name = txtadvName.Text;
        string position = ddlvitri.Text;
        string link = txtadvlink.Text;
        string target = ddltarget.Text;
        string status = ddlstatus.Text;
        string filename = "";
        string txtposition="";
        if ("Quảng Cáo Phải".Equals(position)) {

            txtposition = "advright";
        
        }
        if ("Quảng Cáo Ngân Hàng".Equals(position))
        {

            txtposition = "advbottom";

        }
        if ("Quảng Cáo Giữa".Equals(position))
        {

            txtposition = "advleft";

        }
        if (fuIcon.HasFile)
        {
            filename = fuIcon.FileName;
            fuIcon.SaveAs(Server.MapPath("~/images/") + filename);

        }
        try
        {
            if (data.addAdv(name, txtposition, link, target, filename,status))
            {
                divMessage.InnerHtml = O2S_Message.Success("System", "Successfully");

            }

        }
        catch (Exception ex)
        {

            divMessage.InnerHtml = O2S_Message.Error("System", "Error" + ex.Message);
        }

    }
   
}